home *** CD-ROM | disk | FTP | other *** search
- on HSInit
- global gHSCount, cHSMaxHistory, gHSHistory, gHSState
- set gHSCount to 0
- set cHSMaxHistory to 25
- set gHSHistory to []
- set gHSState to [:]
- end
-
- on HSLoad aName
- global gSIHDPath, gHSCount, gHSHistory, gHSState
- set vFile to FileIO(mnew, "read", gSIHDPath & "USER.DAT")
- if not objectp(vFile) then
- put "Duck=a"
- return
- end if
- set vDone to 0
- set vTarget to "!" & aName
- repeat while not vDone
- set vTmp to vFile(mReadLine)
- if not objectp(vFile) then
- put "Duck=b"
- exit
- end if
- set vTmp to stripCRLF(vTmp)
- if vTmp = vTarget then
- put "Duck=c"
- set vDone to 1
- next repeat
- end if
- if length(vTmp) = 0 then
- exit repeat
- end if
- end repeat
- if not vDone then
- put "Duck=d"
- vFile(mdispose)
- exit
- end if
- set vTmp to vFile(mReadLine)
- if objectp(vFile) then
- set vTmp to stripCRLF(vTmp)
- set gHSState to value(vTmp)
- put "Duck=eb" && vTmp
- put "Duck=ec" && gHSState && voidp(gHSState)
- if voidp(gHSState) then
- set gHSState to [:]
- end if
- else
- put "Duck=f"
- return
- end if
- set vTmp to vFile(mReadLine)
- if objectp(vFile) then
- set vTmp to stripCRLF(vTmp)
- set gHSHistory to value(vTmp)
- if voidp(gHSHistory) then
- set gHSHistory to []
- end if
- set gHSCount to count(gHSHistory)
- else
- return
- end if
- if objectp(vFile) then
- vFile(mdispose)
- end if
- end
-
- on HSSave aName
- global gSIHDPath, gHSHistory, gHSState
- set vSearch to 0
- set vFoundIt to 0
- set vOutFile to FileIO(mnew, "write", gSIHDPath & "USER.BAK")
- if objectp(vFile) then
- exit
- end if
- set vFile to FileIO(mnew, "read", gSIHDPath & "USER.DAT")
- if objectp(vFile) then
- set vSearch to 1
- end if
- set vTmp to "!" & aName & RETURN
- if objectp(vOutFile) then
- vOutFile(mWriteString, vTmp)
- end if
- set vTmp to string(gHSState) & RETURN
- if objectp(vOutFile) then
- vOutFile(mWriteString, vTmp)
- end if
- set vTmp to string([]) & RETURN
- if objectp(vOutFile) then
- vOutFile(mWriteString, vTmp)
- end if
- set vTmp to "[END]" & RETURN
- if objectp(vOutFile) then
- vOutFile(mWriteString, vTmp)
- end if
- set vTarget to "!" & aName
- set vDone to 0
- if objectp(vFile) then
- repeat while not vDone
- set vTmp to vFile(mReadLine)
- if objectp(vFile) then
- set vTmp to stripCRLF(vTmp)
- if length(vTmp) = 0 then
- set vDone to 1
- else
- if vTmp = vTarget then
- set vFoundIt to 1
- set vDone to 1
- else
- set vTmp to vTmp & RETURN
- if objectp(vOutFile) then
- vOutFile(mWriteString, vTmp)
- end if
- end if
- end if
- next repeat
- end if
- set vDone to 1
- end repeat
- if vFoundIt then
- set vDone to 0
- set vTarget to "[END]"
- repeat while not vDone
- set vTmp to vFile(mReadLine)
- if objectp(vFile) then
- set vTmp to stripCRLF(vTmp)
- if length(vTmp) = 0 then
- set vDone to 1
- else
- if vTmp = vTarget then
- set vDone to 1
- end if
- end if
- next repeat
- end if
- set vDone to 1
- end repeat
- end if
- repeat while objectp(vFile)
- set vTmp to vFile(mReadLine)
- put "Duck <" & vTmp & ">"
- if objectp(vFile) and (length(vTmp) > 0) then
- put "Duck2"
- set vTmp to stripCRLF(vTmp)
- set vTmp to vTmp & RETURN
- if objectp(vOutFile) then
- vOutFile(mWriteString, vTmp)
- end if
- next repeat
- end if
- put "Duck3"
- exit repeat
- end repeat
- end if
- set vTmp to "[END]" & RETURN
- if objectp(vOutFile) then
- vOutFile(mWriteString, vTmp)
- end if
- if objectp(vFile) then
- vFile(mdispose)
- end if
- if objectp(vOutFile) then
- vOutFile(mdispose)
- end if
- gSIMiscX(mCopyFile, gSIHDPath & "USER.BAK", gSIHDPath & "USER.DAT")
- end
-
- on HSHistPush aModule, aDescription
- global gHSCount, gHSHistory, gHSState, cHSMaxHistory
- if gHSCount = cHSMaxHistory then
- deleteAt(gHSHistory, gHSCount)
- set gHSCount to gHSCount - 1
- end if
- set vState to getaProp(gHSState, aModule)
- set vHist to [aModule, aDescription, string(vState)]
- add(gHSHistory, vHist)
- set gHSCount to gHSCount + 1
- end
-
- on HSHistPop
- global gHSCount, gHSHistory, gHSState
- if gHSCount = 0 then
- return []
- end if
- set vHist to getAt(gHSHistory, gHSCount)
- deleteAt(gHSHistory, gHSCount)
- set gHSCount to gHSCount - 1
- set vModule to getAt(vHist, 1)
- set vState to value(getAt(vHist, 3))
- setaProp(gHSState, vModule, vState)
- return vModule
- end
-
- on HSHistList
- global gHSCount, gHSHistory
- if gHSCount = 0 then
- return []
- end if
- set vRetList to []
- repeat with I = gHSCount down to 1
- add(vRetList, getAt(getAt(gHSHistory, I), 2))
- end repeat
- return vRetList
- end
-
- on HSStatePut aModule, aKey, aValue
- global gHSState
- set vCurrState to getaProp(gHSState, aModule)
- if not listp(vCurrState) then
- set vCurrState to [:]
- end if
- setaProp(vCurrState, aKey, aValue)
- setaProp(gHSState, aModule, vCurrState)
- end
-
- on HSStateGet aModule, aKey
- global gHSState
- set vCurrState to getaProp(gHSState, aModule)
- if listp(vCurrState) then
- return getaProp(vCurrState, aKey)
- else
- return EMPTY
- end if
- end
-